//
//  ProjectCell.swift
//  GitOSC-Swift
//
//  Created by 李萍 on 15/12/31.
//  Copyright © 2015年 李萍. All rights reserved.
//

import UIKit
import Kingfisher

class ProjectCell: UITableViewCell {

    @IBOutlet weak var userPortraitImageView: UIImageView!
    @IBOutlet weak var nameLabel: UILabel!
    @IBOutlet weak var contentLabel: UILabel!
    @IBOutlet weak var detailLabel: UILabel!
    
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }

    override func setSelected(selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }
    
    func getProjectCommit(commit:GTCommit) {
        let url:NSURL = NSURL(string: "https://git.oschina.net/"+(commit.author?.portrait)!)!
        self.userPortraitImageView.kf_setImageWithURL(url, placeholderImage:UIImage.init(named: "portrait_loading"))
        self.nameLabel.text = commit.authorName
        self.contentLabel.text = commit.title
        self.detailLabel.text = commit.createdAt.substringToIndex(commit.createdAt.startIndex.advancedBy(10))
    }
    
    func getProjectComment(comment:GTComment) {
        let url:NSURL = NSURL(string: "https://git.oschina.net/"+(comment.author?.portrait)!)!
        self.userPortraitImageView.kf_setImageWithURL(url, placeholderImage:UIImage.init(named: "portrait_loading"))
        self.nameLabel.text = comment.author.name
        self.contentLabel.text = comment.note
        self.detailLabel.text = comment.createdAt.substringToIndex(comment.createdAt.startIndex.advancedBy(10))
    }
    
}
